package com.taiji.dicom4platform.admin.service.impl;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taiji.dicom4platform.admin.dao.SysConfigMapper;
import com.taiji.dicom4platform.admin.service.SysConfigService;
import com.taiji.dicom4platform.common.model.entity.SysConfig;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SysConfigServiceImpI
 * @Description
 * @Author HX
 * @Date 2021/8/11 11:26
 **/
@Service
public class SysConfigServiceImpI extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {

    @Override
    public Map<String, Object> getConfigByKeys(String configKeys) {

        String[] keys = configKeys.split(",");
        List<SysConfig> sysConfigs = this.list(Wrappers.<SysConfig>lambdaQuery().in(SysConfig::getConfigKey,keys));
        Map<String, Object> map = new HashMap<>();
        if(ObjectUtil.isNotNull(sysConfigs)){
            for(SysConfig sysConfig:sysConfigs){
                map.put(sysConfig.getConfigKey(),sysConfig.getConfigValue());
            }
        }

        return map;
    }
}
